/*
 * @lc app=leetcode.cn id=187 lang=typescript
 *
 * [187] 重复的DNA序列
 */

// @lc code=start
function findRepeatedDnaSequences(s: string): string[] {
    const res: string[] = [];
    if (s.length <= 10) {
        return [];
    }
    const map = new Map();
    for (let i = 0; i <= s.length - 10; i++) {
        const v = s.slice(i, i + 10);
        map.set(v, (map.get(v) || 0) + 1);
        if (map.get(v) === 2) {
            res.push(v);
        }
    }
    return res;
};

// findRepeatedDnaSequences('AAAAAAAAAAAAA');
// @lc code=end

